home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / dvivga9.zip / FONTFILE.H < prev    next >
Text File  |  1988-05-30  |  7KB  |  243 lines

  1. /* -*-C-*- fontfile.h */
  2. /*-->fontfile*/
  3. /**********************************************************************/
  4. /****************************** fontfile ******************************/
  5. /**********************************************************************/
  6.  
  7. void
  8. fontfile(filelist,font_path,font_name,magnification)
  9. char *filelist[MAXFORMATS];    /* output filename list */
  10. char *font_path;        /* host font file pathname */
  11. char *font_name;        /* TeX font_name */
  12. int magnification;        /* magnification value */
  13. {
  14.  
  15.     /*
  16.     Given a TeX font_name and a magnification value, construct a list of
  17.     system-dependent  host  filenames,  returning  them  in  the   first
  18.     argument.  The files are not guaranteed to exist.  The font names by
  19.     default contains names for the PK,  GF, and PXL font files, but  the
  20.     selection, and search order, may be changed at run time by  defining
  21.     a value for the environment  variable FONTLIST.  See initglob()  for
  22.     details.
  23.     */
  24.  
  25.     register int m;            /* index into filelist[] */
  26.     register INT16 k;            /* loop index */
  27.     float fltdpi;            /* dots/inch */
  28.     int dpi;                /* dots/inch for filename */
  29.  
  30. #if    OS_VAXVMS
  31.     char *tcp;            /* temporary character pointer */
  32.     char *tcp2;            /* temporary character pointer */
  33.     char temp_name[MAXFNAME];    /* temporary filename */
  34. #endif
  35.  
  36.     /*
  37.     We need to convert an old-style ROUNDED integer magnification based
  38.     on 1000 units = 200 dpi to an actual rounded dpi value.
  39.  
  40.     We have
  41.     magnification = round(real_mag) = trunc(real_mag + 0.5)
  42.     which implies
  43.     float(magnification) - 0.5 <= real_mag < float(magnification) + 0.5
  44.  
  45.     We want
  46.     dpi = round(real_mag/5.0)
  47.     which implies
  48.     float(dpi) - 0.5 <= real_mag/5.0 < float(dpi) + 0.5
  49.     or
  50.     5.0*float(dpi) - 2.5 <= real_mag < 5.0*float(dpi) + 2.5
  51.  
  52.     We can combine the two to conclude that
  53.     5.0*float(dpi) - 2.5 < float(magnification) + 0.5
  54.     or
  55.     5.0*float(dpi) - 3 < float(magnification)
  56.     which gives the STRICT inequality
  57.     float(dpi) < (float(magnification) + 3.0)/5.0
  58.     */
  59.  
  60.     fltdpi = (((float)magnification) + 3.0)/5.0;
  61.     dpi = (int)fltdpi;
  62.     if (fltdpi == (float)dpi)
  63.     dpi--;                /* enforce inequality */
  64.  
  65.     for (k = 0; k < MAXFORMATS; ++k) /* loop over possible file types */
  66.       *filelist[k] = '\0';    /* Initially, all filenames are empty */
  67.  
  68.     m = 0;                /* index in filelist[] */
  69.     for (k = 0; k < MAXFORMATS; ++k) /* loop over possible file types */
  70.     {
  71.  
  72. #if    OS_TOPS20
  73.  
  74.     /* Typical results:
  75.         texfonts:amr10.300gf
  76.         texfonts:amr10.300pk
  77.         texfonts:amr10.1500pxl
  78.     */
  79.  
  80.     if (k == gf_index)
  81.         (void)sprintf(filelist[m++], "%s%s.%dgf",
  82.         font_path, font_name, dpi);
  83.     else if (k == pk_index)
  84.         (void)sprintf(filelist[m++], "%s%s.%dpk",
  85.         font_path, font_name, dpi);
  86.     else if (k == pxl_index)
  87.         (void)sprintf(filelist[m++], "%s%s.%dpxl",
  88.         font_path, font_name, magnification);
  89.  
  90. #endif /* OS_TOPS20 */
  91.  
  92. #if    (OS_ATARI | OS_PCDOS)
  93.  
  94.     /* Typical results:
  95.         d:\tex\fonts\300\amr10.gf
  96.         d:\tex\fonts\300\amr10.pk
  97.         d:\tex\fonts\1500\amr10.pxl
  98.     */
  99.  
  100.     if (k == gf_index)
  101.         (void)sprintf(filelist[m++], "%s%d\\%s.gf",
  102.         font_path, dpi, font_name);
  103.     else if (k == pk_index)
  104.         (void)sprintf(filelist[m++], "%s%d\\%s.pk",
  105.         font_path, dpi, font_name);
  106.     else if (k == pxl_index)
  107.         (void)sprintf(filelist[m++], "%s%d\\%s.pxl",
  108.         font_path, magnification, font_name);
  109.  
  110. #endif /* OS_PCDOS */
  111.  
  112. #if    OS_UNIX
  113.  
  114.     /* Typical results (both naming styles are tried):
  115.         /usr/lib/tex/fonts/300/amr10.gf
  116.         /usr/lib/tex/fonts/amr10.300gf
  117.         /usr/lib/tex/fonts/300/amr10.pk
  118.         /usr/lib/tex/fonts/1500/amr10.pxl
  119.         /usr/lib/tex/fonts/amr10.1500pxl
  120.         /usr/lib/tex/fonts/amr10.300pk
  121.     */
  122.  
  123.     if (k == gf_index)
  124.     {
  125.         (void)sprintf(filelist[m++], "%s%d/%s.gf",
  126.         font_path, dpi, font_name);
  127.         (void)sprintf(filelist[m++], "%s%s.%dgf",
  128.         font_path, font_name, dpi);
  129.     }
  130.     else if (k == pk_index)
  131.     {
  132.         (void)sprintf(filelist[m++], "%s%d/%s.pk",
  133.         font_path, dpi, font_name);
  134.         (void)sprintf(filelist[m++], "%s%s.%dpk",
  135.         font_path, font_name, dpi);
  136.     }
  137.     else if (k == pxl_index)
  138.     {
  139.         (void)sprintf(filelist[m++], "%s%d/%s.pxl",
  140.         font_path, magnification, font_name);
  141.         (void)sprintf(filelist[m++], "%s%s.%dpxl",
  142.         font_path, font_name, magnification);
  143.     }
  144.     /*(void)fprintf(stderr,"In fontfile: Path = %s\n",filelist[m - 1]);*/
  145.  
  146. #endif /* OS_UNIX */
  147.  
  148.  
  149. #if    OS_VAXVMS
  150.  
  151.     /* Typical results (both naming styles are tried):
  152.         [tex.fonts.300]amr10.gf
  153.         [tex.fonts]amr10.300gf
  154.         [tex.fonts.300]amr10.pk
  155.         [tex.fonts]amr10.300pk
  156.         [tex.fonts.1500]amr10.pxl
  157.         [tex.fonts]amr10.1500pxl
  158.  
  159.  
  160.     We try a translation of  a logical name here if  what we have in
  161.     fontpath[]    is   not     a   directory  specification     like
  162.     "device:[tex.fonts]" or a rooted logical  name like "tex_fonts:"
  163.     translating to something like "device:[tex.fonts.]"
  164.     */
  165.  
  166.  
  167.     /* Use a straightforward expansion first, in case fontpath is
  168.        a search list. */
  169.     if (k == gf_index)
  170.     {
  171.         (void)sprintf(filelist[m++], "%s[%d]%s.gf", fontpath,
  172.         dpi, font_name);
  173.         (void)sprintf(filelist[m++], "%s%s.%dgf", fontpath,
  174.         font_name, dpi);
  175.     }
  176.     else if (k == pk_index)
  177.     {
  178.         (void)sprintf(filelist[m++], "%s[%d]%s.pk", fontpath,
  179.         dpi, font_name);
  180.         (void)sprintf(filelist[m++], "%s%s.%dpk", fontpath,
  181.         font_name, dpi);
  182.     }
  183.     else if (k == pxl_index)
  184.     {
  185.         (void)sprintf(filelist[m++], "%s[%d]%s.pxl", fontpath,
  186.         magnification, font_name);
  187.         (void)sprintf(filelist[m++], "%s%s.%dpxl", fontpath,
  188.         font_name, magnification);
  189.     }
  190.  
  191.     (void)strcpy(temp_name,fontpath);
  192.     tcp = strrchr(temp_name,']'); /* search for last right bracket */
  193.     if (tcp == (char *)NULL) /* then try logical name translation */
  194.     {
  195.         tcp = GETENV(fontpath);
  196.         if (tcp != (char *)NULL)
  197.         {
  198.             tcp2 = strrchr(tcp,']');
  199.         if (tcp2 == (char *)NULL)
  200.           tcp = (char *)NULL; /* translates to another logical name */
  201.         else
  202.         {
  203.             if (*(tcp2-1) == '.')
  204.                 tcp = (char *)NULL; /* looks like rooted logical name */
  205.             else    /* looks like directory name */
  206.             {
  207.                 (void)strcpy(temp_name,tcp);
  208.                 tcp = strrchr(temp_name,']');
  209.             }
  210.         }
  211.         }
  212.     }
  213.     if (tcp != (char *)NULL)
  214.     {    /* fontpath is something like [tex.fonts] */
  215.         *tcp = '\0';        /* clobber right bracket */
  216.         if (k == gf_index)
  217.         {
  218.         (void)sprintf(filelist[m++], "%s.%d]%s.gf", temp_name,
  219.             dpi, font_name);
  220.         (void)sprintf(filelist[m++], "%s]%s.%dgf", temp_name,
  221.             font_name, dpi);
  222.         }
  223.         else if (k == pk_index)
  224.         {
  225.         (void)sprintf(filelist[m++], "%s.%d]%s.pk", temp_name,
  226.             dpi, font_name);
  227.         (void)sprintf(filelist[m++], "%s]%s.%dpk", temp_name,
  228.             font_name, dpi);
  229.         }
  230.         else if (k == pxl_index)
  231.         {
  232.         (void)sprintf(filelist[m++], "%s.%d]%s.pxl", temp_name,
  233.             magnification, font_name);
  234.         (void)sprintf(filelist[m++], "%s]%s.%dpxl", temp_name,
  235.             font_name, magnification);
  236.         }
  237.     }
  238. #endif /* OS_VAXVMS */
  239.     }
  240.  
  241. }
  242.  
  243.